package com.bw.goods.mvvm.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.recyclerview.widget.RecyclerView;

import com.bw.goods.R;
import com.bw.goods.mvvm.model.entity.HomeBannerEntity;
import com.bw.mvvm_common.mvvm.network.load.LoadImage;
import com.youth.banner.adapter.BannerAdapter;

import java.util.List;

public
/**
 * @author Lishaohe
 * @description:
 * @date :2021/10/15 0015 上午 9:28
 *
 */
class HomeBannerAdapter extends BannerAdapter<HomeBannerEntity, HomeBannerAdapter.HomeBannerViewHolder> {

    public HomeBannerAdapter(List<HomeBannerEntity> datas) {
        super(datas);
    }

    @Override
    public HomeBannerViewHolder onCreateHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_img_banner,parent,false);
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
        itemView.setLayoutParams(lp);
        return new HomeBannerViewHolder(itemView);
    }

    @Override
    public void onBindView(HomeBannerViewHolder holder, HomeBannerEntity data, int position, int size) {
        LoadImage.loadMatchImg(data.imgUrl,holder.imgbanner_item);
    }

    public static class HomeBannerViewHolder extends RecyclerView.ViewHolder {
        ImageView imgbanner_item;
        public HomeBannerViewHolder( View itemView) {
            super(itemView);
            imgbanner_item = itemView.findViewById(R.id.imgbanner_item);
        }
    }

}
